.org 0xE63B0 ; Defense Increase (Tag & Transport)

Defense_Increase_Tag_Transport:

	PUSH 	{R4-R7, LR}
	
	SUB		SP, SP, 4

	LDR 	R4, [Defense_Increase_Tag_Transport_1]
	LDR 	R3, [Defense_Increase_Tag_Transport_2]
	LDR 	R5, [R4, 0]
	LDR 	R4, [R3, 0]
	
	MOV 	R3, 0x98
	
	ADD		R4, R5, R4, LSL 2
	MUL 	R5, R0, R3
	LDR 	R4, [R4, 0x48]	
	MOV		R7, R2
	ADD 	R0, R4, 0x5000
	LDR 	R0, [R0, 0xA58]
	MOV		R4, R1, LSL 4
	ADD		R0, R0, R5
	ADD 	R0, R0, 0x74
	ADD		R0, R0, R1, LSL 4

	MOV		R1, CO_Bodyguard					; Skill: Bodyguard		
	
	MOV		R6, 0
	
	BL 		Check_Skills_Equipped				; Check the Skill is equipped	
	CMP 	R0, 0								; Does CO use that skill?
		
	MOV		R0, R7

	ADDNE 	R6, R6, 10							; If CO use skill, Partner has +10 defense	

;-------------------------------------------------------------------------------
	
	BL		Check_Unit_Type
	
	CMP		R0, Unit_Transport
	
	BNE		Unit_Not_Transport_1
		
	LDR 	R1, [Defense_Increase_Tag_Transport_1]
	LDR 	R0, [Defense_Increase_Tag_Transport_2]
	LDR 	R2, [R1, 0]
	LDR 	R0, [R0, 0]
	
	MOV 	R1, Rank_APC_Guard					; Rank: APC Guard
	
	ADD		R0, R2, R0, LSL 2
	LDR		R0, [R0, 0x48]	
	ADD 	R0, R0, 0x5000
	LDR 	R0, [R0, 0xA58]	
	ADD 	R0, R0, R5
	ADD 	R0, R0, 0x74
	ADD		R0, R0, R4
	
	BL 		Check_Skills_Equipped				; Check the Skill is equipped
	
	CMP 	R0, 0								; Does CO use that skill?
	ADDNE 	R6, R6, 10							; If CO use skill, +10 Transport defense

;-------------------------------------------------------------------------------

Unit_Not_Transport_1:
	
	MOV		R0, R6
	ADD		SP, SP, 4
	
	POP 	{R4-R7, LR}
	
	BX 		LR

;-------------------------------------------------------------------------------		

Defense_Increase_Tag_Transport_1:
	.dw Reg1_Skill
	
Defense_Increase_Tag_Transport_2:
	.dw Reg2_Skill



